<?php
class Game extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('game_model');
	}

	public function index()
	{
		$this->load->helper('url');
		$this->output->cache(5);
		
		$data['games'] = $this->game_model->get_games();
		$data['title'] = 'Games';

		$this->load->view('templates/header', $data);
		$this->load->view('game/index', $data);
		$this->load->view('templates/footer');
	}

	public function view($code)
	{
		$this->output->cache(30);
		
		$data['game'] = $this->game_model->get_games($code);
		
		if (empty($data['game']))
		{
			show_404();
		}

		$data['title'] = $data['game']['title'];

		$this->load->view('templates/header', $data);
		$this->load->view('game/view', $data);
		$this->load->view('templates/footer');
	}
}